/* Copyright (c) 2025 Beijing Semidrive Technology Corporation
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/** *****************************************************************************************************
 *  \file     Uart_Ip.h                                                                                 *
 *  \brief    This file contains interface header for UART MCAL driver.                                 *
 *                                                                                                      *
 * <table>                                                                                              *
 * <tr><th>Date           <th>Version                                                                   *
 * <tr><td>2024/10/29     <td>1.0.0                                                                     *
 * </table>                                                                                             *
 *******************************************************************************************************/

#ifndef UART_IP_H
#define UART_IP_H

#ifdef __cplusplus
extern "C" {
#endif

/********************************************************************************************************
 *                                      Include header files                                            *
 *******************************************************************************************************/
#include "Uart_Types.h"
#include "Uart_Cfg.h"

/********************************************************************************************************
 *                                    Private Type Declarations                                         *
 *******************************************************************************************************/
typedef struct
{
    /* channel config */
    const Uart_ConfigType * config;
    /* channel state */
    Uart_StateType state[UART_CHANNEL_MAX];
    /* driver status */
    Uart_DriverStatusType driverStatus;
} Uart_HandlerType;

/********************************************************************************************************
 *                                  Global Function Declarations                                        *
 *******************************************************************************************************/
uint8 Uart_GetCoreId(void);

Std_ReturnType Uart_Ip_Init(uint8 Channel);

void Uart_Ip_Deinit(uint8 Channel);

Std_ReturnType Uart_Ip_SetBaudrate(uint8 Channel, Uart_BaudrateType Baudrate);

void Uart_Ip_GetBaudrate(uint8 Channel, uint32 * Baudrate);

Std_ReturnType Uart_Ip_SyncSend(uint8 Channel, const uint8* Buffer, uint32 BufferSize, uint32 Timeout);

Std_ReturnType Uart_Ip_SyncReceive(uint8 Channel, uint8* Buffer, uint32 BufferSize, uint32 Timeout);

Std_ReturnType Uart_Ip_AsyncSend(uint8 Channel, const uint8* Buffer, uint32 BufferSize);

Std_ReturnType Uart_Ip_AsyncReceive(uint8 Channel, uint8* Buffer, uint32 BufferSize);

Std_ReturnType Uart_Ip_StartRealTimeRecv(uint8 Channel);

Std_ReturnType Uart_Ip_StopRealTimeRecv(uint8 Channel);

void Uart_Ip_AbortSendingData(uint8 Channel);

void Uart_Ip_AbortReceivingData(uint8 Channel);

Uart_StatusType Uart_Ip_GetTransmitStatus(uint8 Channel, uint32 * BytesRemaining);

Uart_StatusType Uart_Ip_GetReceiveStatus(uint8 Channel, uint32 * BytesRemaining);

void Uart_Ip_IrqHandler(uint8 Channel);

uint8 Uart_Ip_GetChannelIdx(uint32 Base);

#ifdef __cplusplus
}
#endif

#endif /* UART_IP_H */

/* End of file */
